home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Syn Text Editor 2.1.0.46 / synsetup-2.1.0.46.exe / {app} / scripts / cs-rcs.vbs < prev    next >
Text File  |  2003-08-13  |  5KB  |  158 lines

  1. '
  2. '  syn
  3. '  Copyright (C) 2000-2003, Ascher Stefan. All rights reserved.
  4. '  stievie@utanet.at, http://web.utanet.at/ascherst/
  5. '
  6. '  The contents of this file are subject to the Mozilla Public License
  7. '  Version 1.1 (the "License"); you may not use this file except in compliance
  8. '  with the License. You may obtain a copy of the License at
  9. '  http://www.mozilla.org/MPL/
  10. '
  11. '  Software distributed under the License is distributed on an "AS IS" basis,
  12. '  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  13. '  the specific language governing rights and limitations under the License.
  14. '
  15. '  The Original Code is cs-rcs.vbs, released Sun, 26 May 2002 10:55:39 UTC.
  16. '
  17. '  The Initial Developer of the Original Code is Ascher Stefan.
  18. '  Portions created by Ascher Stefan are Copyright (C) 2000-2003 Ascher Stefan.
  19. '  All Rights Reserved.
  20. '
  21. '  Contributor(s): .
  22. '
  23. '  Alternatively, the contents of this file may be used under the terms of the
  24. '  GNU General Public License Version 2 or later (the "GPL"), in which case
  25. '  the provisions of the GPL are applicable instead of those above.
  26. '  If you wish to allow use of your version of this file only under the terms
  27. '  of the GPL and not to allow others to use your version of this file
  28. '  under the MPL, indicate your decision by deleting the provisions above and
  29. '  replace them with the notice and other provisions required by the GPL.
  30. '  If you do not delete the provisions above, a recipient may use your version
  31. '  of this file under either the MPL or the GPL.
  32. '
  33. '  You may retrieve the latest version of this file at the syn home page,
  34. '  located at http://syn.sourceforge.net/
  35. '
  36. ' $Id: cs-rcs.vbs,v 1.2.2.5 2003/08/13 00:38:45 neum Exp $
  37.  
  38.  
  39. ' Version 2.2
  40.  
  41. ' Script to call ComponentSoftware's RCS, if you're not using this implementation
  42. ' from RCS, you may want to access it via the commandline.
  43.  
  44. ' usage: cs-rcs.vbs <dowhat> [filename]
  45.  
  46. ' dowhat can be:
  47. '   -status
  48. '   -history
  49. '   -checkout
  50. '   -checkin
  51. '   -explorer
  52. '   -compare
  53.  
  54. ' usage with syn:
  55. ' - Make a new Tool enter:
  56. '   - Program          : wscript.exe
  57. '   - Arguments        : "cs-rcs.vbs" <dowhat> "$[ActiveDocLong]"
  58. '   - Workingdirectory : something, or leave it blank
  59. '   - Capture Console  : cleared
  60.  
  61. option explicit
  62.  
  63. dim sDoWhat
  64. dim sFileName
  65. dim objFs
  66.  
  67. if WScript.Arguments.Count < 1 then
  68.   MsgBox "To few Arguments." & vbCrLf & "usage: cs-rcs.vbs <dowhat> [filename]", 16, "RCS"
  69.   WScript.Quit
  70. end if
  71.  
  72. sDoWhat = LCase(WScript.Arguments(0))   ' make the arguments case insesitive
  73.  
  74. if WScript.Arguments.Count > 1 then
  75.   sFileName = WScript.Arguments(1)
  76.   set objFs = WScript.CreateObject("Scripting.FileSystemObject")
  77.   if not objFs.FileExists(sFileName) then
  78.     MsgBox "File '" & sFileName & "' does not exist.", 16, "RCS"
  79.     WScript.Quit
  80.   end if
  81. end if
  82.  
  83. select case sDoWhat
  84.   case "-status"
  85.     RcsStatus
  86.   case "-history"
  87.     RcsHistory
  88.   case "-checkout"
  89.     RcsCheckOut
  90.   case "-checkin"
  91.     RcsCheckIn
  92.   case "-explorer"
  93.     RcsExplorer
  94.   case "-compare"
  95.     RcsCompare
  96.   case else
  97.     MsgBox "Unknown directive: '" & sDoWhat & "'.", 16, "RCS"
  98.     WScript.Quit
  99. end select
  100.  
  101. sub RcsStatus()
  102.   dim rcsapp
  103.   set rcsapp = CreateObject("Csrcssrv.Application")
  104.   rcsapp.StatusEx sFileName, false
  105. end sub
  106.  
  107. sub RcsHistory()
  108.   dim rcsapp
  109.   set rcsapp = CreateObject("Csrcssrv.Application")
  110.   rcsapp.History sFileName
  111. end sub
  112.  
  113. sub RcsCheckOut()
  114.   dim rcsapp
  115.   Set rcsapp = CreateObject("Csrcssrv.Application")
  116.   rcsapp.CheckOut sFileName
  117. end sub
  118.  
  119. sub RcsCheckIn()
  120.   dim rcsapp
  121.   set rcsapp = CreateObject("Csrcssrv.Application")
  122.   if rcsapp.GetRCSState(sFileName) = 0 then
  123.     rcsapp.AddToRcs sFileName
  124.   else
  125.     rcsapp.CheckIn sFileName
  126.   end if
  127. end sub
  128.  
  129. sub RcsExplorer()
  130.   dim rcsapp
  131.   set rcsapp = CreateObject("Csrcssrv.Application")
  132.   rcsapp.PrjExplorer ""
  133. end sub
  134.  
  135. sub RcsCompare()
  136.   dim fName
  137.   dim rcsapp
  138.   dim objShell
  139.   set rcsapp = CreateObject("Csrcssrv.Application")
  140.   fName = rcsapp.GetHeadRevision(sFileName)
  141.   set rcsapp = nothing
  142.   
  143.   ' The Diff Tool to compare the two files, you may also use the Tool shipped with CS-RCS (CSDiff.exe)
  144.   const DiffExe = "D:\Eigene Dateien\Delphi Projekte\TextDiff\TextDiff.exe"
  145.  
  146.   if fName <> "" and sFileName <> "" then
  147.     ' Now run a Diff Tool like WinDiff, I use TextDiff (http://rpi.net.au/~ajohnson/delphi/)
  148.     set objShell = WScript.CreateObject("WScript.Shell")
  149.     if objShell.Run(AddQuotes(DiffExe) & " " & AddQuotes(fName) & " " & AddQuotes(sFileName), 1, false) <> 0 then
  150.       MsgBox "Can not start " & DiffExe, 16, "RCS"
  151.     end if
  152.   end if
  153. end sub
  154.  
  155. function AddQuotes(s)
  156.   AddQuotes = Chr(34) & s & Chr(34)
  157. end function
  158.